package com.leyantech.ecp.agenx.loadtest;

import com.leyantech.chaos.kafka.KafkaConsumerStringClient;
import com.leyantech.chaos.kafka.KafkaProducerStringClient;
import com.leyantech.ecp.agenx.loadtest.di.LoadTestModule;

import com.google.inject.Guice;
import com.google.inject.Injector;
import lombok.extern.slf4j.Slf4j;

/**
 * @author eahau, {@literal <eahau@foxmail.com>}
 * @date 2022-10-31.
 */
@Slf4j
public class LoadTester {

  public static void main(String[] args) {

    final Injector injector = Guice.createInjector(new LoadTestModule());

    final KafkaConsumerStringClient consumer = injector
        .getInstance(KafkaConsumerStringClient.class);

    final KafkaProducerStringClient producer = injector
        .getInstance(KafkaProducerStringClient.class);

    consumer.start();

    Runtime.getRuntime().addShutdownHook(new Thread(() -> {
      consumer.destroy();
      producer.destroy();
    }));

  }

}
